<!--
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<section class="create-identity-card">
    <div *ngIf="creatingWithProfile" class="create-card">
        <h1>Create A Business Network Card</h1>
        <connection-profile (profileUpdated)="finishedEditingConnectionProfile($event)"
                            [connectionProfile]="wrappedConnectionProfile"></connection-profile>
    </div>
    <div *ngIf="editingCredentials">
        <edit-card-credentials (idCardAdded)="completeCardAddition($event)"
                      [connectionProfile]="wrappedConnectionProfile"></edit-card-credentials>
    </div>
    <div *ngIf="creatingIdCard" class="create-card">
        <h1>Create A Business Network Card</h1>
        <section class="profiles">
            <div class="description upper"><b>Select blockchain deployment</b></div>
            <div>
                <form #optionForm="ngForm">
                    <div class="create-route" *ngIf="connectionProfileRefs.length>=2">
                        <p>Create a business network card for a Blockchain you already use with Composer:</p>
                        <div class="file-types-list">
                            <div class="file-types-list-item" *ngFor="let profileRef of connectionProfileRefs | slice:0:-1; let i=index">
                                    <input type="radio" id="{{ i }}" name="file-type"
                                        (change)="setConnectionProfile(profileRef)"/>
                                    <label class="radio-label" for="{{ i }}"><h3>{{connectionProfileNames.get(profileRef)}}</h3></label>
                                    <div class="description"><p>{{ connectionProfiles.get(profileRef).description ? connectionProfiles.get(profileRef).description : 'No description specified' }}</p></div>
                            </div>
                        </div>
                    </div>
                    <div class="create-route">
                        <p>Create a business network card for Blockchain you have not connected to before:</p>
                        <div class="file-types-list">
                            <div class="file-types-list-item">
                                <input type="radio" id="new-v1" name="file-type"
                                    (change)="setConnectionProfile('_$v1')">
                                <label class="radio-label" for="new-v1"><h3>Hyperledger Fabric v1.2</h3></label>
                                <div class="description"><p>Connect to a new v1.2 Blockchain</p></div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </section>
        <footer>
            <button type="button" class="secondary" (click)="cancelCreate();">
                <span>Cancel</span>
            </button>
            <button *ngIf = "newConnection" type="button" class="primary" (click)="createWithNewProfile()" [disabled]="!profileChosen">
                <span>Next</span>
            </button>
            <button *ngIf = "!newConnection" type="button" class="primary" (click)="createWithExistingProfile()" [disabled]="!profileChosen">
                <span>Next</span>
            </button>
        </footer>
    </div>
</section>
